import router from '@/router'
import {post} from '@/util/request'

export default {
	namespace:'operStatisticsNetwork',
	namespaced:true,
	state:{
		isLoading:false,
		pageData:{}
	},
	mutations:{
		changeLoading(state,v){
			state.isLoading = v;
		},
		changePagedata(state,v){
			state.pageData = v;
		}
	},
	actions:{
		async reload({commit},data){
			commit('changeLoading',true);
			let res = await post('/stat/newUser/list',data);
			commit('changePagedata',res.data.data);
			commit('changeLoading',false);
		}
	},
	subscriptions({dispatch},router){
		//给路由加监听一旦进入module绑定的页面时dispatch初始化action
		router.afterEach((to,from)=>{
			if(to.name === this.namespace){
				//dispatch('reload',{})
			}
		})
	}
}
